package platformer;

import java.awt.Component;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;

import javax.swing.event.MouseInputListener;

public class Input implements KeyListener, MouseInputListener
{

	private boolean[] keys = new boolean[256];
	private boolean[] mouse = new boolean[4];

	public Input(Component c)
	{
		c.addMouseListener(this);
		c.addKeyListener(this);

	}

	public boolean isKeyPressed(int key) 
	{ 
		if (key > 0 && key < 256) 
		{ 
			return keys[key]; 
		} 

		return false; 
	} 
	
	public boolean isMousePressed(int button) 
	{ 
		return mouse[button];
	} 
	
	/*			Key Listener		*/
	
	public void keyPressed(KeyEvent e) 
	{ 
		if (e.getKeyCode() > 0 && e.getKeyCode() < 256) 
		{ 
			keys[e.getKeyCode()] = true; 
		} 
	} 

	public void keyReleased(KeyEvent e) 
	{ 
		if (e.getKeyCode() > 0 && e.getKeyCode() < 256) 
		{ 
			keys[e.getKeyCode()] = false; 
		} 
	} 

	public void keyTyped(KeyEvent e){}

	/*		Mouse Input Listener  	*/
	
	@Override
	public void mouseClicked(MouseEvent e)
	{

	}

	@Override
	public void mouseEntered(MouseEvent e)
	{

	}

	@Override
	public void mouseExited(MouseEvent e)
	{

	}

	@Override
	public void mousePressed(MouseEvent e)
	{
		if (e.getButton() > 0 && e.getButton() < 4)
			mouse[e.getButton()] = true;
	}

	@Override
	public void mouseReleased(MouseEvent e)
	{
		mouse[e.getButton()] = false;
	}

	@Override
	public void mouseDragged(MouseEvent e)
	{

	}

	@Override
	public void mouseMoved(MouseEvent e)
	{

	} 

}